package com.googlecode.connectlet.web;
/*
import java.io.File;

import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.StandardService;
import org.apache.catalina.startup.Embedded;

public class Tomcat {
	public static StandardService createService(File home) throws Exception {
		return createService(home, 80);
	}

	public static StandardService createService(File home, int port) throws Exception {
		Embedded embedded = new Embedded();
		embedded.setCatalinaHome(home.getPath());
		initEmbedded(embedded);
		Connector connector = embedded.createConnector("0.0.0.0", port, false);
		embedded.addConnector(connector);
		return embedded;
	}

	public static StandardService createService(File home,
			File filePfx, String password) throws Exception {
		return createService(home, 443, filePfx, password);
	}

	public static StandardService createService(File home, int port,
			File filePfx, String password) throws Exception {
		Embedded embedded = new Embedded();
		embedded.setCatalinaHome(home.getPath());
		initEmbedded(embedded);
		Connector connector = embedded.createConnector("0.0.0.0", port, true);
		connector.setAttribute("keystoreType", "PKCS12");
		connector.setAttribute("keystoreFile", filePfx.getPath());
		connector.setAttribute("keystorePass", password);
		connector.setAttribute("truststoreType", "PKCS12");
		connector.setAttribute("truststoreFile", filePfx.getPath());
		connector.setAttribute("truststorePass", password);
		connector.setAttribute("clientAuth", "want");
		embedded.addConnector(connector);
		return embedded;
	}

	private static void initEmbedded(Embedded embedded) {
		// 1. Engine
		Engine engine = embedded.createEngine();
		embedded.addEngine(engine);
		// 2. Host
		Host host = embedded.createHost("localhost",
				embedded.getCatalinaHome() + File.separatorChar + "webapps");
		engine.addChild(host);
		engine.setDefaultHost("localhost");
		// 3. Context
		Context context = embedded.createContext("",
				host.getAppBase() + File.separatorChar + "ROOT");
		host.addChild(context);
	}
}
*/